package com.atguigu.util;

/**
 * @Author 晶晶
 * @Date 2023 03 24 15 58
 **/
public class MySqlUtil_lj {
    public static String getPaperSink() {
        return "create table test_paper( " +
                " id bigint,\n" +
                " paper_id bigint,\n"+
                " paper_title string,\n" +
                " course_id bigint,\n" +
                " create_time date,\n" +
                " update_time date,\n"+
                " publisher_id bigint,\n"+
                " deleted string"+
                ")" + getMysqlConn("test_paper");
    }

    public static String getPaperQuestionSink() {
        return "create table test_paper_question( " +
                " id bigint,\n" +
                " paper_id bigint,\n" +
                " question_id bigint,\n" +
                " score decimal,\n" +
                " create_time date,\n"+
                " publisher_id bigint,\n"+
                " deleted string"+
                ")" + getMysqlConn("test_paper_question");
    }

    public static String getTestExamSink() {
        return "create table test_exam( " +
                " id bigint,\n" +
                " paper_id bigint,\n" +
                " user_id bigint,\n" +
                " score decimal,\n" +
                " duration_sec bigint,\n"+
                " create_time date,\n"+
                " submit_time date,\n"+
                " update_time date,\n"+
                " deleted string"+
                ")" + getMysqlConn("test_exam");
    }

    public static String getTestExamQuestionSink() {
        return "create table test_exam_question( " +
                " id bigint,\n" +
                " paper_id bigint,\n" +
                " exam_id bigint,\n" +
                " question_id bigint,\n" +
                " user_id bigint,\n"+
                " answer string,\n"+
                " is_correct string,\n"+
                " score decimal,\n"+
                " create_time date,\n"+
                " update_time date,\n"+
                " deleted string \n"+
                ")" + getMysqlConn("test_exam_question");
    }

    public static String getVideoSink() {
        return "create table video_info( " +
                " id string,\n" +
                " video_name string,\n" +
                " during_sec bigint,\n" +
                " video_status string,\n" +
                " chapter_id string"+
                ")" + getMysqlConn("video_info");
    }

    public static String getMysqlConn(String tableName) {
        return " WITH ( " +
                "  'connector' = 'jdbc', " +
                "  'url' = 'jdbc:mysql://47.102.112.46:3306/edu', " +
                "  'table-name' = '" + tableName + "', " +
                "  'lookup.cache.max-rows' = '10', " +
                "  'lookup.cache.ttl' = '1 hour', " +
                "  'username' = 'root', " +
                "  'password' = 'qw123456', " +
                "  'driver' = 'com.mysql.cj.jdbc.Driver' " +
                ")";
    }
}
